package com.luo.chengrui.module.sa.dal.mysql.datapermission;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import com.luo.chengrui.module.sa.dal.dataobject.datapermission.DataPermissionDefineDO;
import org.apache.ibatis.annotations.Mapper;
import com.luo.chengrui.module.sa.controller.admin.datapermission.vo.*;

/**
 * 用来定义哪些业务表用来做权限控制，如部门表、费用科目、项目表。一般用来控制权限的都是基础数据表。 Mapper
 *
 * @author luodz
 */
@Mapper
public interface DataPermissionDefineMapper extends BaseMapperX<DataPermissionDefineDO> {

    default PageResult<DataPermissionDefineDO> selectPage(DataPermissionDefinePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DataPermissionDefineDO>()
                .likeIfPresent(DataPermissionDefineDO::getTableName, reqVO.getTableName())
                .eqIfPresent(DataPermissionDefineDO::getTableDesc, reqVO.getTableDesc())
                .likeIfPresent(DataPermissionDefineDO::getPrimaryKeyName, reqVO.getPrimaryKeyName())
                .eqIfPresent(DataPermissionDefineDO::getNameKey, reqVO.getNameKey())
                .likeIfPresent(DataPermissionDefineDO::getParentIdKeyName, reqVO.getParentIdKeyName())
                .likeIfPresent(DataPermissionDefineDO::getForeignKeyName, reqVO.getForeignKeyName())
                .eqIfPresent(DataPermissionDefineDO::getVersion, reqVO.getVersion())
                .orderByDesc(DataPermissionDefineDO::getId));
    }

    default List<DataPermissionDefineDO> selectList(DataPermissionDefineExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DataPermissionDefineDO>()
                .likeIfPresent(DataPermissionDefineDO::getTableName, reqVO.getTableName())
                .eqIfPresent(DataPermissionDefineDO::getTableDesc, reqVO.getTableDesc())
                .likeIfPresent(DataPermissionDefineDO::getPrimaryKeyName, reqVO.getPrimaryKeyName())
                .eqIfPresent(DataPermissionDefineDO::getNameKey, reqVO.getNameKey())
                .likeIfPresent(DataPermissionDefineDO::getParentIdKeyName, reqVO.getParentIdKeyName())
                .likeIfPresent(DataPermissionDefineDO::getForeignKeyName, reqVO.getForeignKeyName())
                .eqIfPresent(DataPermissionDefineDO::getVersion, reqVO.getVersion())
                .orderByDesc(DataPermissionDefineDO::getId));
    }

    default List<DataPermissionDefineDO> selectList(DataPermissionDefineDO reqVO) {
        return selectList(new LambdaQueryWrapperX<DataPermissionDefineDO>()
                .likeIfPresent(DataPermissionDefineDO::getTableName, reqVO.getTableName())
                .eqIfPresent(DataPermissionDefineDO::getTableDesc, reqVO.getTableDesc())
                .likeIfPresent(DataPermissionDefineDO::getPrimaryKeyName, reqVO.getPrimaryKeyName())
                .eqIfPresent(DataPermissionDefineDO::getNameKey, reqVO.getNameKey())
                .likeIfPresent(DataPermissionDefineDO::getParentIdKeyName, reqVO.getParentIdKeyName())
                .likeIfPresent(DataPermissionDefineDO::getForeignKeyName, reqVO.getForeignKeyName())
                .eqIfPresent(DataPermissionDefineDO::getVersion, reqVO.getVersion())
                .orderByDesc(DataPermissionDefineDO::getId));
    }

}
